{% extends 'base.html' %}
{% load static %}
{% load viewflow %}

{% block title %}
Task
{% endblock %}

{% block main_content %}

<div class="box box-primary">
    <div class="box-header with-border">
        <i class="fa fa-tasks"></i>
        <h3 class="box-title">Details</h3>
    </div>
    <div class="box-body">
        <dl class="dl-horizontal">
            <dt>Title</dt>
            <dd>{{ activation.task.summary }}</dd>
            <dt>Created</dt>
            <dd>{{ activation.task.created }}</dd>
            <dt>Started</dt>
            <dd>{{ activation.task.started }}</dd>
            {% if activation.task.finished %}
            <dt>Completed</dt>
            <dd>{{ activation.task.finished }}</dd>
            {% endif %}
            <dt>Status</dt>
            <dd>{{ activation.task.status }}</dd>
        </dl>
    </div>
    <div class="box-footer">
        {% flowurl activation.task 'assign' user=request.user as assign_url %}

        {% if assign_url %}
        <a href="{{ assign_url }}?{{ task }}" class="btn btn-primary">Assign</a>
        {% endif %}

        {% flowurl activation.task 'unassign' user=request.user as unassign_url %}
        {% if unassign_url %}
        <a href="{{ unassign_url }}?{{ task }}" class="btn btn-primary">Unassign</a>
        {% endif %}

        {% flowurl activation.task 'execute' user=request.user as execute_url %}
        {% if execute_url %}
        <a href="{{ execute_url }}?{{ task }}" class="btn btn-primary">Execute</a>
        {% endif %}

        {% comment 'do not show link to task details in task details' %}
            {% flowurl activation.task 'detail' user=request.user as detail_url %}
            {% if detail_url %}
            <a href="{{ detail_url }}?{{ task }}" class="btn btn-primary">Details</a>
            {% endif %}
        {% endcomment %}
        
        <a href="{% url 'example:tasks_in_progress' %}" class="btn btn-default">Tasks</a>
    </div>
</div>

{% endblock main_content %}
